package cn.mq.subscriber;

import cn.bean.MqEvent;
import cn.mq.service.MqService;
import org.springframework.stereotype.Service;

import java.util.function.BiConsumer;

/**
 * 一次性消费Mq
 *
 * @author zhanghui145
 * @date 2022/1/14 10:45
 * @since 1.0.0
 */
@Service
public class OnceMqSubscriber implements BiConsumer<String, String> {

    public OnceMqSubscriber(MqService mqService) {
        mqService.subscribe(MqEvent.MQ_ONCE.getCode(), this);
    }

    @Override
    public void accept(String topic, String msg) {
        System.out.println("Accept:" + topic + "_" + msg);
    }
}
